package com.itboye.ihomebank.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.sax.StartElementListener;
import android.view.View;
import android.view.View.OnClickListener;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.MyApplcation;
import com.itboye.ihomebank.bean.MyGuanJiaBean;
import com.itboye.ihomebank.home.ActivityTianXieHeTongOne;
import com.itboye.ihomebank.me.ActivityPingJiaWorker;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;

/**
 * 我的生活管家（派单中,维修中，待评价）
 *
 */
public class MyGuanJiaAdapter extends MutiplyCommonAdapter<MyGuanJiaBean>{
	List<MyGuanJiaBean> datas;
	int position;
	Context context;
	public MyGuanJiaAdapter(Context context, List<MyGuanJiaBean> datas,
			int... layoutId) {
		super(context, datas, layoutId);
		this.datas=datas;
		this.context=context;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void getItemPosition(int position) {
		this.position=position;
		
	}

	@Override
	public void convert(ViewHolder holder, MyGuanJiaBean t, int type,
			int position) {
		holder.setText(R.id.guanjia_danhao, t.getName());
		
		
		if(t.getType()==1){
			holder.setText(R.id.guanjia_01, "师傅已到");
			holder.setText(R.id.guanjia_02, "取消申请");
		}
		if(t.getType()==2){
			holder.setText(R.id.guanjia_01, "查看师傅");
			holder.setText(R.id.guanjia_02, "修理完成");
		}
		if(t.getType()==3){
			holder.setText(R.id.guanjia_01, "评价师傅");
			holder.setVisible(R.id.guanjia_02, false);
			
			holder.setOnClickListener(R.id.guanjia_01, position,new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					Intent intent=new Intent(context, ActivityPingJiaWorker.class);
					context.startActivity(intent);
					
				}
			});
		}
	}

}
